home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mm / mm-0.90 / seq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-18  |  3.0 KB  |  116 lines

  1. /*
  2.  * Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  * the City of New York.  Permission is granted to any individual or
  4.  * institution to use, copy, or redistribute this software so long as it
  5.  * is not sold for profit, provided this copyright notice is retained.
  6.  */
  7.  
  8. #ifdef RCSID
  9. #ifndef lint
  10. static char *seq_rcsid = "$Header: /f/src2/encore.bin/cucca/mm/tarring-it-up/RCS/seq.h,v 2.1 90/10/04 18:26:37 melissa Exp $";
  11. #endif
  12. #endif /* RCSID */
  13. /*
  14.  * seq.h - sequence keyword table indices
  15.  */
  16.  
  17. /*
  18.  * sequence bitmap access macros (usually defined in sys/param.h)
  19.  */
  20.  
  21. #ifndef NBBY
  22. #define NBBY 8
  23. #endif
  24.  
  25. #ifndef setbit
  26. #define    setbit(a,i)    ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
  27. #define    clrbit(a,i)    ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
  28. #define    isset(a,i)    ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
  29. #define    isclr(a,i)    (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
  30. #endif
  31.  
  32. /*
  33.  * message sequence structure.
  34.  */
  35.  
  36. typedef struct {
  37.     unsigned first;            /* first message in sequence */
  38.                     /* 0 => sequence is invalid */
  39.     unsigned last;            /* last message in sequence */
  40.     unsigned invert;            /* 1 => invert */
  41.     unsigned char *bits;        /* zero-based bit vector */
  42.     struct msgvec *file;        /* backpointer to message "file" */
  43. } *sequence_t;
  44.  
  45. #define sequence_first(s)    ((s)->first)
  46. #define sequence_last(s)    ((s)->last)
  47. #define sequence_bits(s)    ((s)->bits)
  48. #define sequence_file(s)    ((s)->file)
  49. #define in_sequence(s,i)    (isset (sequence_bits(s), i))
  50. #define valid_sequence(s)    (sequence_first(s) != 0)
  51. #define trivial_sequence(s)    (sequence_first(s) == sequence_last(s))
  52. #define sequence_inverted(s)    ((s)->invert)
  53. #define clear_sequence(s) \
  54.     bzero(sequence_bits(s), (s)->file->count / NBBY + 1), \
  55.     sequence_first(s) = sequence_last(s) = sequence_inverted(s) = 0
  56. #define free_sequence(s) \
  57.     if (s) free(sequence_bits(s)), free(s), (s) = 0; else abort()
  58.  
  59. /*
  60.  * Message sequence operators
  61.  */
  62.  
  63. #define SEQ_AFTER    0
  64. #define SEQ_ALL        1
  65. #define SEQ_ANSWERED    2
  66. #define SEQ_BEFORE    3
  67. #define SEQ_CURRENT    4
  68. #define SEQ_DELETED    5
  69. #define SEQ_FLAGGED    6
  70. #define SEQ_FROM    7
  71. #define SEQ_INVERSE    8
  72. #define SEQ_KEYWORD    9
  73. #define SEQ_LAST    10
  74. #define SEQ_LONGER    11
  75. #define SEQ_NEW        12
  76. #define SEQ_ON        13
  77. #define SEQ_PREVIOUS    14
  78. #define SEQ_RECENT    15
  79. #define SEQ_SEEN    16
  80. #define SEQ_SHORTER    17
  81. #define SEQ_SINCE    18
  82. #define SEQ_SUBJECT    19
  83. #define SEQ_TEXT    20
  84. #define SEQ_TO        21
  85. #define SEQ_UNANSWERED    22
  86. #define SEQ_UNDELETED    23
  87. #define SEQ_UNFLAGGED    24
  88. #define SEQ_UNKEYWORD    25
  89. #define SEQ_UNSEEN    26
  90.  
  91. #define SEQ_RANGE    -1
  92.  
  93. /*
  94.  * structure for representing message sequences
  95.  */
  96.  
  97. typedef struct seq_node {
  98.     int type;                /* e.g. SEQ_AFTER */
  99.     union {
  100.     struct {
  101.         int n;            /* number or range of numbers */
  102.         int m;
  103.     } range;
  104.     struct {
  105.         time_t first;        /* date or range of dates */
  106.         time_t last;
  107.     } dates;
  108.     keyword s;            /* string to search for */
  109.     u_long flags;            /* flags to compare against */
  110.     struct seq_node *right;
  111.     } data;
  112.     struct seq_node *left;
  113. } seq_node;
  114.  
  115. #define SEQ_STACK_SIZE 32        /* max number of sequence elements */ 
  116.